package practice1_100;

import java.util.ArrayList;
import java.util.List;

public class Practice208 {

}
class Trie {

    List<String> list;

    /** Initialize your data structure here. */
    public Trie() {
        list=new ArrayList<>();
    }

    /** Inserts a word into the trie. */
    public void insert(String word) {
        int count=0;
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).equals(word)){
                count++;
                break;
            }
        }
        if(count==0) list.add(word);
    }

    /** Returns if the word is in the trie. */
    public boolean search(String word) {
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).equals(word)){
                return true;
            }
        }
        return false;
    }

    /** Returns if there is any word in the trie that starts with the given prefix. */
    public boolean startsWith(String prefix) {
        int size=prefix.length();
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).length()>=size&& list.get(i).substring(0,size).equals(prefix)){
                return true;
            }
        }
        return false;
    }
}
